package com.ruoyi.project.visit.service.impl;

import com.ruoyi.project.visit.domain.DoctorPatientHistory;
import com.ruoyi.project.visit.mapper.DoctorPatientHistoryMapper;
import com.ruoyi.project.visit.service.IDoctorPatientHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 历史病例服务实现类
 */
@Service
public class DoctorPatientHistoryServiceImpl implements IDoctorPatientHistoryService {
    @Autowired
    private DoctorPatientHistoryMapper doctorPatientHistoryMapper;

    /**
     * 新增病例
     * @param doctorPatientHistory
     * @return
     */
    @Override
    public int insertDoctorPatientHistory(DoctorPatientHistory doctorPatientHistory) {
        // 生成病例编码， 格式是 SXT+时间戳
        doctorPatientHistory.setHistoryNumber("SXT"+System.currentTimeMillis());

        return doctorPatientHistoryMapper.insertDoctorPatientHistory(doctorPatientHistory);
    }

    /**
     * 修改病例
     * @param doctorPatientHistory
     * @return
     */
    @Override
    public int updateDoctorPatientHistory(DoctorPatientHistory doctorPatientHistory) {
        return doctorPatientHistoryMapper.updateDoctorPatientHistory(doctorPatientHistory);
    }

    /**
     * 主键查询病例
     * @param historyId
     * @return
     */
    @Override
    public DoctorPatientHistory selectByHistoryId(Integer historyId) {
        return doctorPatientHistoryMapper.selectByHistoryId(historyId);
    }

    /**
     * 根据患者主键查询历史病例
     * @param doctorPatientHistory
     * @return
     */
    @Override
    public List<DoctorPatientHistory> selectListByPatientId(DoctorPatientHistory doctorPatientHistory) {
        return doctorPatientHistoryMapper.selectListByPatientId(doctorPatientHistory);
    }
}
